<template>
	<view class="hot-tags">
		<view class="header">
			<image src="headImage" mode="widthFix"></image>
		</view>
		<view class="wrap">
			<u-row v-if="row in rows">
				<u-col v-for="(item, index) in row" :span="spanMap[row.length]">
					<view @click="onClick(item)">
						<image :src="item.imageUrl" mode="widthFix"></image>
					</view>
				</u-col>
			</u-row>
		</view>
	</view>
</template>

<script>
	export default {
		name: "HotTags",
		props: {
			headImage: {
				type: String,
				default: ''
			},
			rows: {
				type: Array,
				default: () => ([])
			}
		},
		data() {
			return {
				spanMap {
					1: 12,
					2: 6,
					3: 4,
					4: 3
				}
			}
		},
		methods: {
			onClick(item) {
				this.$emit('click', item)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.hot-tags {
		.header {
			width: 100%;
			height: auto;
		}
	}
</style>
